package day_806;

import java.awt.Transparency;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;

import javax.imageio.stream.FileCacheImageOutputStream;
import javax.imageio.stream.FileImageOutputStream;

import org.junit.Test;

public class IOdome {
	public static void main(String[] args) {
		FileReader fileReader = null;
		FileWriter fileWriter = null;

		try {
			fileReader = new FileReader("IO.txt");
			fileWriter = new FileWriter("IOS.txt");
			char[] buffer = new char[10];
			int length = 0;
			while ((length = fileReader.read(buffer)) != -1) {
				fileWriter.write(buffer, 0, length);
			}

		} catch (FileNotFoundException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
		try {
			fileReader.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
		try {
			fileWriter.close();
		} catch (IOException e) {
			e.printStackTrace();
		}

	}


@Test
public void test(){
	//字节流
	FileInputStream fileInputStream=null;
	FileOutputStream fileOutputStream=null;
	try {
		 fileInputStream=new FileInputStream("001.png");
		 fileOutputStream=new FileOutputStream("002");
		 byte[] buffer=new byte[1024];
		 int length=0;
		 while((length=fileInputStream.read(buffer))!=-1){
			 fileOutputStream.write(buffer,0,length);
		 }
	} catch (FileNotFoundException e) {
		e.printStackTrace();
	} catch (IOException e) {
		e.printStackTrace();
	}finally{
		try {
			if(fileInputStream!=null){
			fileInputStream.close();
			}
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		try {
			if(fileOutputStream!=null){
			fileOutputStream.close();
			}
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
			}
	
	
	
}
@Test
public void test1(){
	
}

}
